package com.wc.acwing.博弈论.蛋糕游戏;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/2/19 13:50
 * @description
 * https://www.acwing.com/problem/content/6121/
 */
public class Main {
    /**
     * 思路:
     * A同学一定会合并中间的, 如果合并边上的, 会导致边上的变大, 被 B 同学拿走
     * B同学一定是拿边上的, 所以我们只需要计算拿边上能构成的最大值, A同学吃剩下的
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 500010;
    static int[] a = new int[N];
    static long[] pre = new long[N], suf = new long[N];
    static int n;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextInt();
            long sum = 0;
            for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
            for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] + a[i];
            for (int i = 1; i <= n; i++) sum += a[i];
            for (int i = 1, j = n; i < j; i++, j--) {
                int tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
            for (int i = 1; i <= n; i++) suf[i] = suf[i - 1] + a[i];
            int bound = (n - 2) / 2;
            long maxv = 0;
            for (int i = 0; i <= bound; i++) {
                maxv = Math.max(maxv, pre[i] + suf[bound - i]);
            }
            out.println(sum - maxv + " " + maxv);
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

